function changePreviousPage() {
    var pathArray = window.location.pathname.split('/');
    var page = parseInt(pathArray[pathArray.length - 1]) - 1;
    if (page === 0) {
        alert('已经是第一页啦');
    } else {
        var old_href = window.location.href;
        var href = old_href.substring(0, old_href.lastIndexOf('/')) + '/';
        window.location.href = href + page;
    }
}

function changeNextPage() {
    var pathArray = window.location.pathname.split('/');
    var page = parseInt(pathArray[pathArray.length - 1]) + 1;
    var old_href = window.location.href;
    var href = old_href.substring(0, old_href.lastIndexOf('/')) + '/';
    window.location.href = href + page;
}

function changePage() {
    var numberInput = document.querySelector('.number-input');
    var change = numberInput.value;
    var parts = window.location.pathname.split('/');
    var index = parts.findIndex(part => part === 'page');
    var oldurl = parts.slice(0, index + 1).join('/') + '/';
    var reqUrl = oldurl + change;
    // console.log(reqUrl);
    window.location.href = reqUrl;
}

var pathArray = window.location.pathname.split('/');
var pageSelectedId = '#page' + pathArray[pathArray.length - 1];
var pageSelected = document.querySelector(pageSelectedId).querySelector('a');
pageSelected.classList.add('selected');

var typeSelectedId = pathArray[pathArray.length - 3];
var typeSelected = document.querySelector('#' + typeSelectedId).querySelector('a');
typeSelected.classList.add('selected');


